<?php
namespace app\controller;
use app\model\User;
use think\facade\View;
use think\Request;


class Show
{
    public $name = '徐林栋';
    public $age  = '19';
    const PI = 3.14;

    public function index(Request $request){
        //$name = 'Mr.Lee';
        //require 'test/1.php';
        //View::assign('name','Mr.Lee');

        View::assign([
            'name'  =>  'Mr.Lee',
            'email' =>  'lee@163.com'
        ]);
        //return View::fetch('index');
        //设置过滤。
//        return View::filter(function ($content){
//            return $content;
//        })->fetch('index');
        //View::config([]);
        return View::fetch();

    }

    public function output(){
        $arr = ['name'=>'Mr.Lee','age'=>100];
        return View::fetch('output',[
            'arr'   =>  $arr,
            'obj'   =>  $this
        ]);
    }

    public function fn(){
        return '方法';
    }

//    public function loop(){
//        $list = User::select();
//        //提交到模板区域
//        return View::fetch('loop',[
//            'list' => $list
//        ]);
//    }

    public function loop(){
        return View::fetch('loop', [
            'list' => User::paginate(5)
        ]);
    }
}